package day09.Homework;

public class MyList {

    private Node head;
    private Node tail;


    public void addFirst(Object value){
        //链表为空
        //head = new Node(null,value,null);
        //链表不为空
        head = new Node(tail, value, head);
    }

    public void addLast(Object value){
        tail = new Node(head, value, tail);
    }



    public Object get(int i){
        return null;
    }


    public int size(){
        return 0;
    }

    public void display() {
        Node pointer = this.head;
        while(pointer != null){
            System.out.print(pointer.value+" ");
            pointer = pointer.next;
        }
    }

    private static class Node{
        Object value;
        Node prev;
        Node next;
        public Node(Node prev, Object value, Node next){
            this.value = value;
            this.prev = prev;
            this.next = next;
        }
    }


}
